<template>
  <div>父级传参：{{d3}}</div>
  <button @click="add">加加</button>
</template>

<script>
import { reactive, ref, toRefs, inject } from "vue";
export default {
  name: "",
  // 定义模板
  components: {},
  //在创建组件之前执行
  setup(props, context) {
    const state = reactive({
      name: "你好1",
      d3:inject('d3')
    });
    const num = ref(0);
    console.log(state.d3)
    const add = () => {
      state.d3++
    }
    return {
      ...toRefs(state),
      num,
      add
    };
  },
};
</script>
<style scoped lang ='less'>
</style>